package com.hewep.demo.device.mina.core;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

public abstract class Routes {
	private final Map<String, Class<? extends Controller>> map = new HashMap<String, Class<? extends Controller>>();

	public Routes add(String method, Class<? extends Controller> controllerClass) {
		if (method == null){
			throw new IllegalArgumentException("The method can not be null");
		}
		
		method = method.trim();
		
		if ("".equals(method))
			throw new IllegalArgumentException("The controllerKey can not be blank");
		if (controllerClass == null)
			throw new IllegalArgumentException("The controllerClass can not be null");
		
		if (map.containsKey(method))
			throw new IllegalArgumentException("The controllerKey already exists: " + method);
		
		map.put(method, controllerClass);
		
		return this;
	}

	public Set<Entry<String, Class<? extends Controller>>> getEntrySet() {
		return map.entrySet();
	}
}
